package com.hhl.lamda.onvertstream2list;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author HHL
 * @description
 * @date 2018/11/19 - 9:11
 */
public class ConvertStream2List {

    public static void main(String[] args) {

        Stream<String> language = Stream.of("java", "python", "node");

        // 将Stream转化为list
        List<String> result = language.collect(Collectors.toList());
//        java python node
        result.forEach(System.out::print);
        System.out.println();




        // Yet another example, filter a number 3 and convert it to a List.
        Stream<Integer> number = Stream.of(1, 2, 3, 4, 5);
        // 过滤掉 3 ，将其他 3 以外的数字转化为list集合
        List<Integer> result2 = number.filter(x -> x != 3).collect(Collectors.toList());
        // 1 2 4 5
        result2.forEach(System.out::print);
        System.out.println();



    }
}
